<?php
namespace plugin\banmichaoqiangbizhi\model;
use think\Model;
use think\facade\Db; 
class PluginBanmiBanmichaoqiangbizhiSearchKey extends Model
{
      public function finds($map,$field)
     { 
         if ($field) {
            $finds = PluginBanmiBanmichaoqiangbizhiSearchKey::where($map)->field($field)->findOrEmpty();
         } else {
             $finds = PluginBanmiBanmichaoqiangbizhiSearchKey::where($map)->findOrEmpty();
         }
         return $finds;
     }
      public function paginate($map,$field)
     {
      if ($field) {
          $list = PluginBanmiBanmichaoqiangbizhiSearchKey::where($map)->order('sort', 'asc')->field($field)->paginate(20);
      } else {
          $list = PluginBanmiBanmichaoqiangbizhiSearchKey::where($map)->order('sort', 'asc')->paginate(20);
      }
      $list = $list->all();
      $total = PluginBanmiBanmichaoqiangbizhiSearchKey::where($map)->count();
      $data['list']=$list;
      $data['total']=$total;
      return $data; 
     }
      public function adds($request,$field)
     { 
         unset($request['id']);
         $user = new PluginBanmiBanmichaoqiangbizhiSearchKey;
         $user->save($request);
         return $user->id;
     }
     public function updates($map,$request,$field)
     { 
     $user = PluginBanmiBanmichaoqiangbizhiSearchKey::where($map)->find();  
     
    if ($user) {
          return $user->save($request);    
     }  
       return false;  
     }
       public function dels($map)
     {
      $user = PluginBanmiBanmichaoqiangbizhiSearchKey::where($map)->find();  
      if ($user) {
            return PluginBanmiBanmichaoqiangbizhiSearchKey::where($map)->delete();
      }  
        return false;  
     }
     //模型方法


}